java program to find first and last digits of a number